package util;

import java.io.IOException;
import java.net.NetworkInterface;
import java.util.Enumeration;

public class AddressIP {

	public String getInterfaces() throws IOException {

		try {
			String addr = null;

			Enumeration<NetworkInterface> en = NetworkInterface	.getNetworkInterfaces();
			while (en.hasMoreElements()) {
				NetworkInterface ni = en.nextElement();
				if (!ni.isLoopback() && ni.isUp()) {
					String endereco[] = ni.getInterfaceAddresses().get(1).getAddress().toString().split("/");
					addr = endereco[1].toString();
				}
			}
			return addr;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
